<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style: none;
        }

        .wrap {
            width: 480px;
            margin: 50px auto;
        }

        .wrap .nav {
            width: 480px;
            overflow: hidden;
            text-align: center;
            line-height: 40px;
        }

        .wrap .nav li {
            float: left;
            width: 80px;
            border: 1px solid #333;
            box-sizing: border-box;
        }

        .wrap .nav li+li {
            border-left: 0;
        }

        .wrap .nav .active {
            background-color: aquamarine;
            color: #fff;
        }

        .wrap .content {
            width: 100%;
            height: 300px;
            border: 1px solid #333;
            box-sizing: border-box;
            border-top: 0;
        }

        .wrap .content .part {
            width: 100%;
            height: 100%;
            text-align: center;
            line-height: 300px;
            display: none;
        }

        .wrap .content .show {
            display: block;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div class="nav">
            <li class="active">link_01</li>
            <li>link_02</li>
            <li>link_03</li>
            <li>link_04</li>
            <li>link_05</li>
            <li>link_06</li>
        </div>
        <div class="content">
            <div class="part show">part_1</div>
            <div class="part">part_2</div>
            <div class="part">part_3</div>
            <div class="part">part_4</div>
            <div class="part">part_5</div>
            <div class="part">part_6</div>
        </div>
    </div>
</body>
<script>

    var liList = document.querySelectorAll(".nav li");
    var partList = document.querySelectorAll(".content .part");
    console.log(liList);

    for (var i = 0; i < liList.length; i++) {
        var li = liList[i];
        li.onclick = function () {

            for (var j = 0; j < liList.length; j++) {
                // liList[j].setAttribute("class", "");
                // partList[j].setAttribute("class", "part");

                liList[j].className = "";
                partList[j].classList.remove("show");

            }

            var index = Array.from(liList).indexOf(this);
            // this.setAttribute("class", "active");

            // liList[index].setAttribute("class", "active");
            // partList[index].setAttribute("class", "part show");

            liList[index].className = "active";
            partList[index].classList.add("show");

        }
    }
    console.log("循环结束后", li, i);



</script>

</html>